const Koa = require('koa');
//Application
const app = new Koa();
//路由
const router = require('koa-router')();

//配置项
const config = require('./config');
console.log(`redis_hosts: ${config.redis_hosts} redis_port: ${config.redis_port}`);

//使用路由 下面三个路由将被包含在app的router中
const index = require('./routes/index');
const users = require('./routes/users');
const api = require('./routes/api');

router.use('/', index.routes(), index.allowedMethods());
router.use('/users', users.routes(), users.allowedMethods());
router.use('/api', api.routes(), api.allowedMethods());
app.use(router.routes(), router.allowedMethods());

//开启服务,监听3001端口
app.listen(3001);

console.log(`process.env.NODE_ENV: ${process.env.NODE_ENV}`);
